﻿# -*- coding: utf-8 -*-

# Crispy Plotter, a fast and easy-to-use function plotter
# Copyright (C) 2010 Konrad Kölzer

# Crispy Plotter is free software, see License.txt for details.

# Conversion script for .po files
# Written by Konrad Kölzer

"""
Converts gnugettext .po files to .mo files. This file should be placed in the
locale folder.
"""

import glob
import subprocess
import os.path

files = glob.glob('*/LC_MESSAGES/*.po')
print('Found %d file(s)' % len(files))
for f in files:
    outfile = os.path.splitext(f)[0] + '.mo'
    print('Processing %s => %s' % (f, outfile))
    args = ['msgfmt', f, '--output-file=%s' % outfile, '-v']
    p = subprocess.Popen(args, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    result = p.wait()
    if result != 0:
        print('Could not convert file "%s".' % f)
    

